package cj.hrm.dao;


import cj.hrm.dao.provider.DeptDynaSqlProvider;
import cj.hrm.entity.Dept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;
import java.util.Map;

import static cj.hrm.util.common.HrmConstants.DEPTTABLE;


public interface DeptDao {
	//查询
	@Select("select * from "+DEPTTABLE+" ")
	List<Dept> selectAllDept();
	
	@Select("select * from "+DEPTTABLE+" where name like CONCAT('%',#{content},'%')"
			+ "or remark like CONCAT('%',#{content},'%')")
	List<Dept> selectLikeAllDept(String content);
	//根据id查询部门
	@Select("select * from "+DEPTTABLE+" where id = #{id}")
	Dept selectById(Integer id);
	//根据参数查询部门总数
	@SelectProvider(type=DeptDynaSqlProvider.class,method="count")
	Integer countDept(Map<String, Object> params);
	//动态查询
	@SelectProvider(type=DeptDynaSqlProvider.class,method="selectWhitParam")
	List<Dept> selectByPage(Map<String, Object> params);
	//动态插入部门
	@SelectProvider(type= DeptDynaSqlProvider.class,method="insertDept")
	void insert_Dept(Dept dept);
	//动态修改部门
	@SelectProvider(type=DeptDynaSqlProvider.class,method="updateDept")
	void update_Dept(Dept dept);
	// 根据id删除部门
	@Delete(" delete from "+DEPTTABLE+" where id = #{id} ")
	void deleteDeptById(Integer id);
	@SelectProvider(type=DeptDynaSqlProvider.class,method="count")
	Integer count(Map<String, Object> params);
	@Select("select * from "+DEPTTABLE+" where name = #{name}")
	Dept getDeptByName(String name);
	
}
